#!/bin/bash
# 停止所有Python进程
pkill -9 -f "manage.py runserver"
sleep 2

# 清理Python缓存
find /aiops/backend -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null
find /aiops/backend -type f -name "*.pyc" -delete 2>/dev/null

# 启动Django
cd /aiops/backend
python manage.py runserver 0.0.0.0:8000 > /aiops/logs/backend.log 2>&1 &
echo "后端已重启，进程ID: $!"

# 等待启动
sleep 5

# 测试API
echo "测试API..."
curl -s http://localhost:8000/api/system-info/ | head -5
